package org.wheel.module.core.entity.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class MessagePageData {

    /**
     * 当前页码
     */
    private long pageNo;
    /**
     * 每页分页数
     */
    private long pageSize;
    /**
     * 数据总条数
     */
    private long totalCount;
    /**
     * 数据分页总页码
     */
    private long totalPage;
    /**
     * 数据对象
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    public long getTotalPage(){
        if(this.pageSize>0 && this.totalCount>0){
            return (totalCount + pageSize - 1) / pageSize;
        }
        return this.totalPage;
    }
}
